home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
pctj8502.arc
/
WINDOW.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1986-09-14
|
3KB
|
124 lines
{ Turbo Pascal removable window system }
{ Copyright 1984 Michael A. Covington }
{ Requirements: IBM PC or close compatible. }
{ Screen must be in text mode, on page 1, }
{ either mono or color card. }
{ Call INITWIN before calling MKWIN or RMWIN. }
const maxwin = 5; { maximum number of windows open at once }
type imagetype = array [1..4096] of char;
windimtype = record
x1,y1,x2,y2: integer
end;
var
win: { Global variable package }
record
dim: windimtype; { Current window dimensions }
depth: integer;
stack: array[1..maxwin] of
record
image: imagetype; { Saved screen image }
dim: windimtype; { Saved window dimensions }
x,y: integer { Saved cursor position }
end
end;
crtmode: byte absolute $0040:$0049;
crtwidth: byte absolute $0040:$004A;
monobuffer: imagetype absolute $B000:$0000;
colorbuffer: imagetype absolute $B800:$0000;
procedure initwin;
{ Records initial window dimensions }
begin
with win.dim do
begin x1:=1; y1:=1; x2:=crtwidth; y2:=25 end;
win.depth:=0
end;
procedure boxwin(x1,y1,x2,y2:integer);
{ Draws a box, fills it with blanks, and makes it the current }
{ window. Dimensions given are for the box; actual window is }
{ one unit smaller in each direction. }
{ This routine can be used separately from the rest of the }
{ removable window package. }
var x,y: integer;
begin
window(1,1,80,25);
{ Top }
gotoxy(x1,y1);
write(chr(213));
for x:=x1+1 to x2-1 do write(chr(205));
write(chr(184));
{ Sides }
for y:=y1+1 to y2-1 do
begin
gotoxy(x1,y);
write(chr(179), ' ':x2-x1-1, chr(179))
end;
{ Bottom }
gotoxy(x1,y2);
write(chr(212));
for x:=x1+1 to x2-1 do write(chr(205));
write(chr(190));
{ Make it the current window }
window(x1+1,y1+1,x2-1,y2-1);
gotoxy(1,1)
end;
procedure mkwin(x1,y1,x2,y2:integer);
{ Create a removable window }
begin
{ Increment stack pointer }
with win do depth:=depth+1;
if win.depth>maxwin then
begin
writeln(^G,' Windows nested too deep ');
halt
end;
{ Save contents of screen }
if crtmode = 7 then
win.stack[win.depth].image := monobuffer
else
win.stack[win.depth].image := colorbuffer;
win.stack[win.depth].dim := win.dim;
win.stack[win.depth].x := wherex;
win.stack[win.depth].y := wherey;
{ Create the window }
boxwin(x1,y1,x2,y2);
win.dim.x1 := x1+1;
win.dim.y1 := y1+1; { Allow for margins }
win.dim.x2 := x2-1;
win.dim.y2 := y2-1;
end;
procedure rmwin;
{ Remove the most recently created removable window }
{ Restore screen contents, window dimensions, and }
{ position of cursor. }
begin
if crtmode = 7 then
monobuffer := win.stack[win.depth].image
else
colorbuffer := win.stack[win.depth].image;
with win do
begin
dim := stack[depth].dim;
window(dim.x1,dim.y1,dim.x2,dim.y2);
gotoxy(stack[depth].x,stack[depth].y);
depth := depth - 1
end
end;